package gui;

import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import java.awt.Dimension;

public class JFrameAdminMainPage extends JFrame {

	private JPanel contentPane;
	public static String ID;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					JFrameAdminMainPage frame = new JFrameAdminMainPage();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public JFrameAdminMainPage() {
		setTitle("Admin - Main page");
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 551, 410);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnUserManagement = new JButton("User Management");
		btnUserManagement.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				JFrameAdminUserManagement jFrameUserManagement = new JFrameAdminUserManagement();
				jFrameUserManagement.setVisible(true);
				dispose();
			}
		});
		btnUserManagement.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnUserManagement.setBounds(150, 280, 250, 60);
		contentPane.add(btnUserManagement);
		
		JButton btnQuizManagement = new JButton("Quiz Management");
		btnQuizManagement.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				JFrameAdminQuizManagement jFrameQuizManagement = new JFrameAdminQuizManagement();
				jFrameQuizManagement.setVisible(true);
				dispose();
			}
		});
		btnQuizManagement.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnQuizManagement.setBounds(150, 80, 250, 60);
		contentPane.add(btnQuizManagement);
		
		JButton btnPasswordManagement = new JButton("Password Management");
		btnPasswordManagement.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				JFrameAdminChangePassword jFrameAdminChangePassword = new JFrameAdminChangePassword();
				jFrameAdminChangePassword.setVisible(true);
				dispose();
			}
		});
		btnPasswordManagement.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnPasswordManagement.setBounds(150, 180, 250, 60);
		contentPane.add(btnPasswordManagement);
		
		JButton btnSignOut = new JButton("");
		btnSignOut.setPreferredSize(new Dimension(80, 80));
		btnSignOut.setMinimumSize(new Dimension(80, 80));
		btnSignOut.setMaximumSize(new Dimension(80, 80));
		btnSignOut.setSize(new Dimension(80, 80));
		btnSignOut.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				if  (JOptionPane.showConfirmDialog(JFrameAdminMainPage.this,
						"Do you want to sign out?","Confirm",JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {

						JFrameLogin jFrameLogin = new  JFrameLogin();
						jFrameLogin.setVisible(true);
						dispose();
				}
			}
		});
		btnSignOut.setFont(new Font("Tahoma", Font.PLAIN, 18));
		btnSignOut.setBounds(450, 20, 50, 50);
		contentPane.add(btnSignOut);
		
		JLabel lblAdminMenu = new JLabel("Admin Menu");
		lblAdminMenu.setHorizontalAlignment(SwingConstants.CENTER);
		lblAdminMenu.setFont(new Font("Tahoma", Font.BOLD, 30));
		lblAdminMenu.setBounds(125, 10, 300, 50);
		contentPane.add(lblAdminMenu);
		
		ImageIcon iconLogout = new ImageIcon("resource/btn_signout.png") ;
		btnSignOut.setIcon(iconLogout);
	}
}
